package com.mallcloud.mall.common.data.tenant;

import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestInterceptor;

/**
 * 租户信息拦截
 *
 * 重写TenantSqlParser,如果有系统管理员,想看到租户A数据的同时也能看到租户B的数据的实现逻辑 https://zhuanlan.zhihu.com/p/577381996
 */
@Configuration
public class MallTenantConfiguration {

	@Bean
	public RequestInterceptor mallFeignTenantInterceptor() {
		return new MallFeignTenantInterceptor();
	}

	@Bean
	public ClientHttpRequestInterceptor mallTenantRequestInterceptor() {
		return new TenantRequestInterceptor();
	}

}
